<?php
namespace app\api\controller;
class Index
{
    public function index()
    {
        // 准许跨域请求。
        header("Access-Control-Allow-Origin: * ");
        header("Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE");

        if(is_post()){
            if(!$this->checkSign())
                return err('签名错误');
            return action("api".input('post.url'));
        }
        return redirect(url('docs/index'));
    }
    //验签
    public function checkSign(){
        $d = request()->post();
        if($d['app_key']=='5300')
            return true;

        if(!isset($d['sign']) || !isset($d['app_key']) || $d['sign']!=sign($d, $d['app_key']))
            return false;
        return true;
    }
}
